package com.by.facade.enums.userbehaviorlog;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

@Getter
@AllArgsConstructor
public enum UserBehaviorTypeEnum {

    REGISTER(UserBehaviorTypeEnum.REGISTER_CODE, "注册"),
    SUBSCRIBE_MP(UserBehaviorTypeEnum.SUBSCRIBE_MP_CODE, "关注公众号"),
    UN_SUBSCRIBE_MP(UserBehaviorTypeEnum.UN_SUBSCRIBE_MP_CODE, "取消关注公众号"),
    BIND_PHONE(UserBehaviorTypeEnum.BIND_PHONE_CODE, "绑定手机号"),
    CREATE_ORDER(UserBehaviorTypeEnum.CREATE_ORDER_CODE, "创建订单"),
    ADD_WXCP_FRIEND(UserBehaviorTypeEnum.ADD_WXCP_FRIEND_CODE, "加好友"),
    JOIN_WXCP_GROUP(UserBehaviorTypeEnum.JOIN_WXCP_GROUP_CODE, "入群"),
    WXCP_REMARK(UserBehaviorTypeEnum.WXCP_REMARK_CODE, "企微备注"),
    SYS_TAG(UserBehaviorTypeEnum.SYS_TAG_CODE, "系统内部标签"),
    WXCP_TAG(UserBehaviorTypeEnum.WXCP_TAG_CODE, "企微标签"),
    ORDER_PAY_SUCCESS(UserBehaviorTypeEnum.ORDER_PAY_SUCCESS_CODE, "支付成功"),
    SYS_USER_UPDATE_WXCP_REMARK(UserBehaviorTypeEnum.SYS_USER_UPDATE_WXCP_REMARK_CODE, "系统用户更新备注"),
    USER_DEL_FOLLOW_USER(UserBehaviorTypeEnum.USER_DEL_FOLLOW_USER_CODE, "用户删除跟进人"),
    SYSUSER_DEL_EXTERNAL_CONTACT(UserBehaviorTypeEnum.SYSUSER_DEL_EXTERNAL_CONTACT_CODE, "系统用户删除客户"),
    CREATE_SPU_PAY_PLAN(UserBehaviorTypeEnum.CREATE_SPU_PAY_PLAN_CODE, "创建付款计划"),
    CHANGE_SPU_PAY_PLAN_TARGET_AMOUNT(UserBehaviorTypeEnum.CHANGE_SPU_PAY_PLAN_TARGET_AMOUNT_CODE, "变更付款计划目标金额"),
    SCAN_QR(UserBehaviorTypeEnum.SCAN_QR_CODE, "扫码"),
    FOLLOW_COURSE(UserBehaviorTypeEnum.FOLLOW_COURSE_CODE, "跟课"),
    FINISH_COURSE(UserBehaviorTypeEnum.FINISH_COURSE_CODE, "完课"),
    SPU_PAY_PLAN_BIND_SCENE_VAL(UserBehaviorTypeEnum.SPU_PAY_PLAN_BIND_SCENE_VAL_CODE, "付款计划绑定场景值"),
    ;

    private Integer code;
    private String desc;

    private static final Map<Integer, UserBehaviorTypeEnum> MAP = Arrays.stream(UserBehaviorTypeEnum.values())
            .collect(Collectors.toMap(UserBehaviorTypeEnum::getCode, Function.identity()));

    public static UserBehaviorTypeEnum resolve(Integer code) {
        return MAP.get(code);
    }

    public static final int REGISTER_CODE = 1;
    public static final int SUBSCRIBE_MP_CODE = 2;
    public static final int UN_SUBSCRIBE_MP_CODE = 3;
    public static final int BIND_PHONE_CODE = 4;
    public static final int CREATE_ORDER_CODE = 5;
    public static final int ADD_WXCP_FRIEND_CODE = 6;
    public static final int JOIN_WXCP_GROUP_CODE = 7;
    public static final int WXCP_REMARK_CODE = 8;
    public static final int SYS_TAG_CODE = 9;
    public static final int WXCP_TAG_CODE = 10;
    public static final int ORDER_PAY_SUCCESS_CODE = 11;
    public static final int SYS_USER_UPDATE_WXCP_REMARK_CODE = 12;
    public static final int USER_DEL_FOLLOW_USER_CODE = 13;
    public static final int SYSUSER_DEL_EXTERNAL_CONTACT_CODE = 14;
    public static final int CREATE_SPU_PAY_PLAN_CODE = 15;
    public static final int CHANGE_SPU_PAY_PLAN_TARGET_AMOUNT_CODE = 16;
    public static final int SCAN_QR_CODE = 18;
    public static final int FOLLOW_COURSE_CODE = 19;
    public static final int FINISH_COURSE_CODE = 20;
    public static final int SPU_PAY_PLAN_BIND_SCENE_VAL_CODE = 21;

}
